package com.example.weatherjavaui.slice;

import com.example.weatherjavaui.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;
import ohos.agp.window.dialog.ToastDialog;

public class ResourceAbilitySlice extends AbilitySlice {

    private static Button button_cancel;
    private static Button button_add_res;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_layout_resource_file);
        buttonSet();
    }
    private void buttonSet() {
        button_cancel = (Button) findComponentById(ResourceTable.Id_botton_cancel_res);
        button_add_res = (Button) findComponentById(ResourceTable.Id_botton_add_res);

        button_add_res.setClickedListener(this:: ClickedButton);
        button_cancel.setClickedListener(this:: ClickedButton);
    }

    private void ClickedButton(Component component) {
        if (component == button_add_res) {
            new ToastDialog(getContext()).setText("点了确认").show();
        }
        if (component == button_cancel) {
            new ToastDialog(getContext()).setText("点了取消").show();
        }
    }


    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
